#include "statewrapper.h"
#include "menustate.h"
#include "playstate.h"
#include "pausestate.h"

statewrapper::statewrapper(ptrContainer* container){
    w_container = container;
    w_allstates = new basestate*[3];
    w_allstates[0] = new menustate(w_container, this);
    w_allstates[1] = new playstate(w_container, this);
    w_allstates[2] = new pausestate(w_container, this);
    w_activestate = w_allstates[0];
    w_statecount = 3;
}

statewrapper::~statewrapper(){
    delete w_allstates[0];
    delete w_allstates[1];
    delete w_allstates[2];
    delete [] w_allstates;
}

void statewrapper::draw(int &drawstate){
    if(w_activestate){
        w_activestate->draw(drawstate);
    }
}

bool statewrapper::update(int &endtime, int &ticktime){
    if(w_activestate){
        return w_activestate->update(endtime, ticktime);
    }
    return false;
}

void statewrapper::changestate(int deststate){
    if(deststate >= w_statecount || deststate < 0){
        return;
    }
    w_activestate = w_allstates[deststate];
    w_activestate->enterstate();
}
